<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8">
		<title>发送短信</title>
		<link rel="stylesheet" href="__ADMIN_PATH__/component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>发送标题</label>
						<div class="layui-input-block">
							<input type="text" name="money" autocomplete="off" value="{$info['name']}" class="layui-input" />
						</div>
					</div>

				</div>
				<div class="main-container">

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>发送人群</label>
						<div class="layui-input-block">
							<input type="text" name="num" autocomplete="off" placeholder="请输入充值券数量" value="1" class="layui-input" />
						</div>
					</div>

				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
<!--					<input type="hidden" name="id" value="{$info['id'] ?= $info['id']}" />-->
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="coupon">
						<i class="layui-icon layui-icon-ok"></i>
						生成
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>

		</form>
		<script src="__ADMIN_PATH__/component/layui/layui.js"></script>
		<script src="__ADMIN_PATH__/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery', 'popup', 'loading', 'laydate'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				var popup = layui.popup;
				let loading = layui.loading;
				let laydate = layui.laydate;
				/**
				 * 限制时间
				 */
				var myDate = new Date();  //获取当前时间
				var startTime = laydate.render({
					elem: "#startTime", 
					type: "datetime",
					min:myDate.toLocaleString(),  //转化当前时间格式
					done:function(value,date)
					{
						if(value!=""){
							date.month=date.month-1;
		        			endTime.config.min=date;
				    	}else
				    	{
				    		endTime.config.min=startTime.config.min;
				    	}
					}
				});
				var endTime = laydate.render({
					elem: "#endTime", 
					type: "datetime",
					min:myDate.toLocaleString(),  //转化当前时间格式
					done:function(value,date)
					{
						if(value!=""){
							date.month=date.month-1;
		        			startTime.config.max=date;
			    	    }else
			    	    {
			    	    	startTime.config.max=endTime.config.max;
			    	    }
					}
				});
				/**
				 * 监听到期类型选择
				 */
				form.on('radio(expire_type)', function(data){
					//console.log(data);
					let value = data.value;
					if(value == 0)
					{
						//领取生效
						$('#expire_type_hour').show();
						$('#expire_type_day').hide();
					}else
					{
						//固定日期
						$('#expire_type_hour').hide();
						$('#expire_type_day').show();
					}
				});
				/**
				 * 表单提交
				 */
				form.on('submit(coupon)', function(data) {
					var arr_box = [];

					// return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
					$.ajax({
						url:"{:url('Mark/addmark')}",
						type:"POST",
						dataType:"JSON",
						data:data.field,
						beforeSend: function () {
							loading.Load(1, "");
		                },
		                complete: function () {
		                	loading.loadRemove();
		                },
		                success:function(res)
		                {
		                	if(res.code == 0)
		                	{
		                		//正常业务
		                		popup.success(res.msg, function(){
		                			var index = parent.layer.getFrameIndex(window.name);
		                			parent.location.reload();
		                			parent.layer.close(index); //再执行关闭
	                        	});
		                	}else
		                	{
		                		//业务异常
		                		popup.warning(res.msg);
		                	}
		                },
		                error:function()
		                {
		                	loading.loadRemove();
		                	popup.failure('服务器错误');
		                }
		            });
		            return false;
		        });
		    });
		</script>
	</body>
</html>